<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
    	<!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
    		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>糖果计划</title>
		<script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
		<script src="//cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js"></script>
		<script src="__CDN__/assets/js/template-web.js" type="text/javascript" charset="utf-8"></script>
		<script src="__CDN__/assets/libs/layer/dist/mobile/layer.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="__CDN__/assets/css/activity.css" />
	</head>

	<body>
		<div class="header">
			<div class="header-img"><img src="__CDN__/assets/img/active/title@2x.png" /></div>
			<div class="act-time">活动时间：2018-06-26 至 2018-06-30</div>
		</div>
		<div class="main1">
			<div class="main1-sec">
				<img src="__CDN__/assets/img/active/icon_wallet_01@2x.png" />
				<p>资产管理</p>
				<span>多重防盗</span>
				<span>轻松管理</span>
			</div>
			<div class="main1-sec">
				<img src="__CDN__/assets/img/active/icon_qr_02@2x.png" />
				<p>一键转账</p>
				<span>安全便捷</span>
				<span>实时可查</span>
			</div>
			<div class="main1-sec main1-sec3">
				<img src="__CDN__/assets/img/active/icon_hq_03@2x.png" />
				<p>关注行情</p>
				<span>行情有数</span>
				<span>从容投资</span>
			</div>
		</div>
		<div class="main2">
			<div class="main2-sec">
				<span class="main2-span1"> </span>
				<div class="main2-title">第一步：选择您要领取的钱包</div>
				<span class="main2-span2"> </span>
			</div>
			<form action="{:url('api/activity/getLottery')}" method="post" id="form">
				<input class="main2-put1" type="email" value="" placeholder="请输入钱包地址" />
				<input class="main2-put2" type="text" value="" placeholder="请输入邀请码" />
				<hr />
				<button class="main2-put3">领取cam</button>
				<div class="main2-def">默认邀请码</div>
			</form>
		</div>
		
		<div class="main22">
			<div class="main22-sec">
				<span class="main22-span1"> </span>
				<div class="main22-title">第一步：选择您要领取的钱包</div>
				<span class="main22-span2"> </span>
			</div>
			<div class="main22-sec2">
				<img src="__CDN__/assets/img/active/icon_Symbol_01@2x.png"/>
				<p>
					<span>恭喜您获得<span class="number"></span>个CAM</span><br />
					<span>继续邀请好友获得更多CAM吧</span>
				</p>
				<img src="__CDN__/assets/img/active/icon_Symbol_02@2x.png"/>
			</div>
		</div>
		
		<div class="main3">
			<div class="main3-sec">
				<span class="main3-span1 main3-span"></span>
				<div class="main3-title">第二步：邀好友&#x3000;领CAM</div>
				<span class="main3-span2 main3-span"> </span>
			</div>
			<div class="main3-sec2">
				<p>&#x3000;<img src="__CDN__/assets/img/active/icon_Symbol_01@2x.png" />每邀请一位好友下载并注册“币伯钱包”</p>
				<p>APP，即可再获取2个CAM<img src="__CDN__/assets/img/active/icon_Symbol_02@2x.png" /></p>
			</div>
			<div class="main3-sec3">
				<ul></ul>
			</div>
			<hr class="hr2" />
			<div class="main3-sec4">
				<div class="main3-sec4-d1">我的邀请码</div>
				<div class="main3-sec4-d2">
					<div>
						<span class="copyText"></span>
						<textarea id="input">这是幕后黑手</textarea>
						<img class="copy" src="__CDN__/assets/img/active/icon_copy@2x.png" />
					</div>
					<div class="share">分享</div>
				</div>
			</div>
			<hr class="hr3" />
			<div class="main3-sec5">
				<div class="main3-sec5-d1 main3-sec5-d">
					<img src="__CDN__/assets/img/active/icon_recom@2x.png" alt="" />
					<p>
						<span>推荐好友数量</span>
						<span class="peopel"></span>
					</p>
				</div>
				<div class="main3-sec5-d2 main3-sec5-d">
					<img src="__CDN__/assets/img/active/icon_coin@2x.png" alt="" />
					<p>
						<span>奖励</span>
						<span class="num"></span>
					</p>
				</div>
			</div>
		</div>

		<div class="main4">
			<div class="main4_logo">活动说明</div>
			<div class="main4_sec">
				<dl class="main4_sec1">
					<dt>活动时间：</dt>
					<dd>2018-06-26 至 2018-06-30</dd>
				</dl>
				<dl class="main4_sec2">
					<dt>活动对象：</dt>
					<dd>币伯钱包用户</dd>
				</dl>
				<dl class="main4_sec3">
					<dt>活动流程：</dt>
					<dd>
						<p><span class="list"> </span><span class="list_text">活动对象须为“币伯钱包“APP用户，且用户已在APP中“创建CAM钱包”；</span></p>
						<p><span class="list"> </span><span class="list_text">完成上一步骤后，用户均可免费获得1-5个CAM；</span></p>
						<p><span class="list"> </span><span class="list_text">用户每通过指定推荐码成功邀请一位好友下载并注册“币伯钱包”APP，且“创建CAM钱包”，用户可再额外获得2个CAM奖励。</span></p>
						<p><span class="list"> </span><span class="list_text">邀请次数不限，用户通过推荐码成功邀请的好友越多，获得的CAM奖励将相应增加。</span></p>
					</dd>
				</dl>
				<dl class="main4_sec4">
					<dt>活动详情：</dt>
					<dd>
						<p><span class="list"> </span><span class="list_text">用户可通过“币伯钱包“APP查看活动所获糖果数：“我的”  &#10132;  “活动”  &#10132;  “有你计划活动”</span></p>
						<p><span class="list"> </span><span class="list_text">活动所得糖果将在活动结束5个工作日内发放至用户指定钱包账户。</span></p>
						<p><span class="list"> </span><span class="list_text">同一设备登录即视为同一用户。</span></p>
						<p><span class="list"> </span><span class="list_text">以下行为在本活动中将视为违规，主办方有权取消用户参与活动资格，且用户活动所得糖果将不予发放：</span>
							<ul>
								<li>a. 以非法盈利为目的参与活动；</li>
								<li>b. 恶意使用多个账号参与活动；</li>
								<li>c. 通过机器人软件或其他自动方式参与活动；</li>
								<li>d. 其他非真实领取的作弊行为。</li>
							</ul>
							</p>
							<p><span class="list"> </span><span class="list_text">若活动期间出现不可抗因素或大面积恶意套利行为、通讯线路故障、计算机大规模瘫痪等原因导致活动难以继续开展，主办方有权修改、暂停或取消本活动。</span></p>
							<p><span class="list"> </span><span class="list_text">若因用户电子设备不支持或其他系统问题导致用户无法正常参与活动等情况，主办方不承担相关责任。</span></p>
							<p><span class="list"> </span><span class="list_text">活动最终解释权归“币伯钱包”研发中心所有。</span></p>
					</dd>
				</dl>
			</div>
		</div>
		
		<div class="main5">
			<div class="main5-sec"><span>恭喜您获得</span> <span class="main5-num"></span> <span>CAM</span></div>
			<hr />
			<div class="main5-sec2">糖果将在活动结束5个工作日内发送至您指定的钱包地址，请注意查收！</div>
			<div class="main5-close">&#10005;</div>
		</div>
		
		<div class="main6">
			<div class="main6-sec"><span>邀请码：</span><span class="invite"></span></div>
			<div class="main6-sec2">我在“币伯钱包”邀你一起瓜分1,000,000CAM！</div>
			<div class="main6-sec3">时不可待，速来抢币！</div>
			<div class="main6-sec4">请在浏览器中打开链接</div>
			<div class="main6-sec5"></div>
			<hr />
			<textarea id="input2">这是幕后黑手</textarea>
			<div class="main6-sec6">复制分享</div>
			<div class="main6-close">&#10005;</div>
		</div>
		
		<div class="main7">
			<div class="main7-sec"></div>
		</div>
		
		<!--遮罩层-->
	<div id="screen"></div>
	</body>

</html>
<script type="text/javascript">
    var activityId = '';
    var userId = '';
    function openAlert(msg) {
        layer.open({
            content: msg,
            style: 'background-color:#f00; color:#fff; border:none;',
            shade: false
        });
    }
    function apiForm(mesg){
        activityId = mesg.activity_id;
        userId = mesg.user_id;
        var mobile = mesg.mobile,
		    email = mesg.email,
            deviceType = mesg.device_type,
			url = "{:url('api/activity/getUserReceive')}";
        $.ajax({
        	type:'POST',
        	url:url,
        	data:{
               activity_id: activityId,
               user_id: userId,
               mobile: mobile,
               email: email,
               device_type: deviceType
        	},
            dataType: 'json',
            success:function (resp) {
                var data = resp.data,
				    code = resp.code,
			        msg = resp.msg;
			    if ( code == 1 ) {
                   var status = data.status,
                       num = data.cam,
                       my_receive = data.myReceive,
                       rankList = data.rankList;
                   if ( status == 1 ) {
                       $('.number').text(num);
                       $('.main22').show();
                       $('.main2').hide();
                   }else {
                       $('.main2').show();
                       $('.main22').hide();
                   }
                   $('.copyText').text(my_receive.invitation_code);
                   $('.peopel').text(my_receive.recommend_num + '人');
                   $('.num').text(my_receive.invite_quantity + 'cam');
                   rank(rankList);
			   }else {
			       if ( data == 0 ) {
                       window.location.href = '../activity/ending';
				   }else {
			           openAlert(msg);
				   }
			   }
           },
           error:function () {
              alert('请求数据出错！');
           }
        });

        return mesg;
    }
    //排名
	function rank(list) {
        if ( list.length == 0 ) {
            var html = '<li><span style="display: inherit;text-align: center;">暂无排名</span></li>';
		}else {
            $.each(list,function (index, value, arr) {
                var html = '<li>'+
                    '<span>NO.1</span>'+
                    '<span>'+value.mobile+'</span>'+
                    '<span>推荐'+value.recommend_num+'人</span>'+
                    '</li>';
            });
		}
        $('.main3-sec3 ul').append(html);
    }
    //抽奖
	$('.main2-put3').click(function () {
         var form = $('#form'),
	         address = $('.main2-put1').val(),
			 code = $('.main2-put2').val();
		$.ajax({
			 type:'POST',
			 url:form.attr('action'),
             dataType: 'json',
			 data:{
                 activity_id: activityId,
                 user_id: userId,
                 address: address,
                 invitation_code: code
			 },
			success:function (resp) {
				//使得用户无法滚动
				document.documentElement.style.overflow = 'hidden';
				if ( resp.code != 0 ) {
                    var num = resp.data;
                    $('.main5-num').text(num);
                    $('.number').text(num);
                    $('#screen').fadeIn(200);
                    $('.main5').fadeIn(300);
				}else {
                    var msg = resp.msg;
                    openAlert(msg);
				}
            },
			error:function () {
				console.log('请求数据出错！');
            }
		});
    });
    //分享
    $('.share').click(function() {
        //使得用户无法滚动
        document.documentElement.style.overflow = 'hidden';
        var url = "{:url('api/activity/getShoreUrl')}";
        $.ajax({
            type:'GET',
            url:url,
            dataType: 'json',
            data:{},
            success:function (resp) {
                var url = resp.data,
					code = resp.code,
                    invite = $('.copyText').text();
                if ( code == 1 ) {
                    $('.main6-sec5').text(url);
                    $('.invite').text(invite);
                    $('#screen').fadeIn(200);
                    $('.main6').fadeIn(300);
				}
            },
            error:function () {
                console.log('请求数据出错！');
            }
        });
    });
	//适配移动端
		function resize() {
			var deviceWidth = document.documentElement.clientWidth;
			if (deviceWidth < 240) deviceWidth = 240;
				document.documentElement.style.cssText = 'font-size:' + (deviceWidth / 15) + 'px!important';
		}
		window.addEventListener('resize',resize);
		resize();
		
		
		//复制
		var copy = document.getElementsByClassName('copy')[0];
		copy.addEventListener('click',function(){
			var text = document.getElementsByClassName("copyText")[0].innerText;
			var input = document.getElementById("input");
			input.value = text; // 修改文本框的内容
			input.select(); // 选中文本
			document.execCommand("copy"); // 执行浏览器复制命令
			alert(text)
		});
		
		//默认邀请码
		$('.main2-def').click(function(){
			$('.main2-put2').val("a76486");
		});
		
		// 点击关闭按钮弹出框要隐藏掉
		$('.main5-close').click(function(){
			$('.main5').fadeOut(300);
			$('#screen').fadeOut(200);
			$('.main2').hide();
			$('.main22').show();
			//使得用户可以滚动
			document.documentElement.style.overflow = 'auto';
		});

		// 点击关闭按钮弹出框要隐藏掉
		$('.main6-close').click(function(){
			$('.main6').fadeOut(300);
			$('#screen').fadeOut(200);
			//使得用户可以滚动
			document.documentElement.style.overflow = 'auto';
		});
		
		//复制
		var copy2 = document.getElementsByClassName('main6-sec6')[0];
		copy2.addEventListener('click',function(){
			var text;
			var text1 = document.getElementsByClassName("main6-sec")[0].innerText;
			var text2 = document.getElementsByClassName("main6-sec2")[0].innerText;
			var text3 = document.getElementsByClassName("main6-sec3")[0].innerText;
			var text4 = document.getElementsByClassName("main6-sec4")[0].innerText;
			var text5 = document.getElementsByClassName("main6-sec5")[0].innerText;
			text = text1 + " \n " + text2 + " \n " + text3 + " \n " + text4 + " \n " + text5;
			var input = document.getElementById("input2");
			input.value = text; // 修改文本框的内容
			input.select(); // 选中文本
			document.execCommand("copy"); // 执行浏览器复制命令
			alert(text)
		});
</script>